# import nibabel as nib
import numpy as np
import SimpleITK as sitk
import os

# 将无法打开的int32数据转为可打开的utf-8类型
# files = os.listdir('prediction_new')
# for file1 in files:
#     file = os.path.join('prediction_new',file1)
file = "C:\\study\\FFR\\myProject\\mytest\\mydata\\prediction_00179.nii.gz"
image_path = file
labelImage = sitk.ReadImage(image_path)  # in_file是nii.gz文件的路径
imag = sitk.GetArrayFromImage(labelImage)
vol = imag.astype('uint8')
# get image data
image_out = sitk.GetImageFromArray(vol)
sitk.WriteImage(image_out, '00177.nii.gz')
